home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part2 / 11577 < prev    next >
Encoding:
Text File  |  1996-08-05  |  1.1 KB  |  52 lines

  1. Newsgroups: comp.lang.c++
  2. Path: ncrgw2.ncr.com!ncrhub2!lznj2!lziss3!netnews
  3. From: Arnold Bursian <arnold.bursian@germany.ncr.com>
  4. Subject: Re: Can you overload a constructor?
  5. Content-Type: text/plain; charset=us-ascii
  6. Message-ID: <31493335.8C5@germany.ncr.com>
  7. Sender: netnews@lziss3.lincroftnj.ncr.com (51[news]-Netnews Admin)
  8. Content-Transfer-Encoding: 7bit
  9. Organization: AT&T GIS Lincroft, NJ USA
  10. References: <Do859K.K9B@watserv3.uwaterloo.ca>
  11. Mime-Version: 1.0
  12. Date: Fri, 15 Mar 1996 09:07:01 GMT
  13. X-Mailer: Mozilla 2.0GoldB1 (Win95; I)
  14.  
  15. jfournie@sciborg.uwaterloo.ca wrote:
  16. > Greetings,
  17. > I am new to C++ and just wanted to make sure it
  18. > was OK to overload a constructor.  gnu c++
  19. > doesn't have a problem with it, but is it normally
  20. > done?
  21. > regards
  22. > JP Fournier
  23. > jfournie@sciborg.uwaterloo.ca
  24.  
  25. Sure, you do it all the time! Just make sure you're calling one of the parent's constructors.
  26.  
  27. class B
  28. {
  29.   B( int i, int j );
  30.   ...
  31. };
  32.  
  33. B::B( int i, int j )
  34. {
  35.   ...
  36. }
  37.  
  38. class A : public B
  39. {
  40.   A( int x, int y );
  41.   ...
  42. };
  43.  
  44. A::A( int x, int y ) : B( 3, 4 )
  45. {
  46.   ...
  47. }
  48.